Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

yallist

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yallist

Yet Another Linked List

  • 4.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is yallist?

The yallist package is a Node.js module that provides a linked list data structure. It allows for efficient insertion and removal of elements from the beginning and end of the list, as well as iteration and various list manipulations.

What are yallist's main functionalities?

Create a linked list

This feature allows you to create a new linked list. You can pass in any number of arguments to the constructor, and they will be added to the list in order.

const Yallist = require('yallist')
const list = new Yallist(1, 2, 3)

Push items to the list

Pushing items to the list adds them to the end. This is similar to the Array.prototype.push method.

list.push('a')
list.push('b')

Pop items from the list

Popping items from the list removes the last item and returns it. This is similar to the Array.prototype.pop method.

list.pop()

Unshift items to the list

Unshifting items to the list adds them to the beginning. This is similar to the Array.prototype.unshift method.

list.unshift('new item')

Shift items from the list

Shifting items from the list removes the first item and returns it. This is similar to the Array.prototype.shift method.

list.shift()

Iterate over the list

You can iterate over the list using a for-of loop, similar to how you would with an array.

for (let item of list) {
  console.log(item)
}

Map a function over the list

The map method creates a new list with the results of calling a provided function on every element in the calling list.

const mappedList = list.map(x => x * 2)

Reduce the list

The reduce method applies a function against an accumulator and each element in the list to reduce it to a single value.

const sum = list.reduce((acc, x) => acc + x, 0)

Other packages similar to yallist

FAQs

Package last updated on 30 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc